/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/1/5 15:20
 */
public class ThreadDemo21 {
    static Object LOCKER = new Object();

    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            try{
                synchronized (LOCKER){
                    while(true){
                        System.out.println("A");
                        LOCKER.notify();
                        LOCKER.wait();
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        });
        Thread t2 = new Thread(()->{
            try{
                synchronized (LOCKER){
                    while(true){
                        System.out.println("B");
                        LOCKER.notify();
                        LOCKER.wait();
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        });
        t2.start();
        t1.start();
    }
}
